﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
// custom headers
#include "TranslatorManager.h"
#include "ILegend.h"
#include "DebugMessage.h"
#include "EnableCompileWarning_The_LAST_IncludeInCpp.h" 

namespace gmepgcs
{
    ILegend::ILegend()
    {
    }

    ILegend::~ILegend()
    {
    }

    std::shared_ptr<ILegend> ILegend::Clone()
    {
        std::shared_ptr<ILegend> spClone = std::make_shared<ILegend>();
        DBG_WARN_AND_RETURN_NULLPTR_UNLESS(spClone, L"spClone 为空", L"GMEP", L"2024-01-30");
        spClone->Id = Id;
        spClone->Name = Name;
        spClone->Type = Type;
        spClone->Thumbnail = Thumbnail;
        spClone->StandardSource = StandardSource;
        spClone->Uid = Uid;
        spClone->EnterpriseResourceId = EnterpriseResourceId;
        spClone->EnterpriseResourceVersion = EnterpriseResourceVersion;
        spClone->PlaceholderFrom = PlaceholderFrom;
        spClone->EnterpriseSPUId = EnterpriseSPUId;

        return spClone;
    }

    bool ILegend::operator==(const ILegend &other)
    {
        // compare id or Uid
        if (Id != other.Id || Uid != other.Uid)
        {
            return false;
        }

        return true;
    }

    bool ILegend::operator!=(const ILegend &other)
    {
        return !operator==(other);
    }
    
    int32_t ILegend::GetLegendTypeInDigitalModule(ILegend::LegendType legendType)
    {
        switch (legendType)
        {
        case ILegend::LegendType::Plan:
            return 0;
        case ILegend::LegendType::Elevation:
            return 1;
        case ILegend::LegendType::Profile:
            return 2;
        case ILegend::LegendType::Electric:
            return 3;
        default:
            return -1;
        }
    }

    std::wstring ILegend::GetTypeName(ILegend::LegendType legendType)
    {
        switch (legendType)
        {
        case ILegend::LegendType::Plan:
            return GBMP_TR(L"平面图例");
        case ILegend::LegendType::Elevation:
            return GBMP_TR(L"立面图例");
        case ILegend::LegendType::Profile:
            return GBMP_TR(L"侧面图例");
        case ILegend::LegendType::Electric:
            return GBMP_TR(L"电气图例");
        default:
            return std::wstring();
        }
    }

    bool ILegend::GetMajorTypeName(const ILegend::LegendType legendType, std::wstring& major, std::wstring& type)
    {
        major = GBMP_TR(L"通用");
        switch (legendType)
        {
        case ILegend::LegendType::Invalid:
            return false;
        case  ILegend::LegendType::Plan:
            type = GBMP_TR(L"平面");
            break;
        case  ILegend::LegendType::Profile:
            type = GBMP_TR(L"侧面");
            break;
        case  ILegend::LegendType::Elevation:
            type = GBMP_TR(L"立面");
            break;
        case ILegend::LegendType::Electric:
            type = GBMP_TR(L"平面");
            major = GBMP_TR(L"电气");
            break;
        }
        return true;
    }
}